package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.EcologyCollectionShareProfitConf;
import com.sc.nft.entity.vo.merchantPledgeTask.AdminEcologyIncomeConfNewDetailsVO;
import com.sc.nft.entity.vo.merchantPledgeTask.NewAdminEcologyIncomeConfDetailsVO;
import com.sc.nft.enums.EcologyCollectionShareProfitTypeEnum;
import com.sc.nft.mapper.EcologyCollectionShareProfitConfMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author：LiGen
 * @Package：com.sc.nft.dao
 * @Project：sc_metago
 * @name：DaoEcologyPointsWalletDao
 * @Date：2024/11/26 11:08
 * @Filename：DaoEcologyPointsWalletDao
 */
@Slf4j
@Repository
public class EcologyCollectionShareProfitConfDao extends ServiceImpl<EcologyCollectionShareProfitConfMapper, EcologyCollectionShareProfitConf> {
    public boolean saveAll(List<EcologyCollectionShareProfitConf> shareProfitConfList) {
        return baseMapper.saveAll(shareProfitConfList);
    }

    public List<EcologyCollectionShareProfitConf> listByConfId(Long confId) {
        LambdaQueryWrapper<EcologyCollectionShareProfitConf> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(EcologyCollectionShareProfitConf::getConfId,confId);
        return list(lambdaQueryWrapper);
    }

    public List<EcologyCollectionShareProfitConf> getListByType(EcologyCollectionShareProfitTypeEnum type) {
        LambdaQueryWrapper<EcologyCollectionShareProfitConf> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(EcologyCollectionShareProfitConf::getType,type);
        return list(lambdaQueryWrapper);
    }

    public AdminEcologyIncomeConfNewDetailsVO getConfList(Long confId) {
        return baseMapper.getConfList(confId);
    }

    /**
     * 通过生态配置id获取分润配置
     *
     * @param id
     * @return
     */
    public List<EcologyCollectionShareProfitConf> getListByConfId(Long id) {
        LambdaQueryWrapper<EcologyCollectionShareProfitConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(EcologyCollectionShareProfitConf::getConfId, id);
        return list(wrapper);
    }

    public boolean getCountByConfId(Long confId) {
        LambdaQueryWrapper<EcologyCollectionShareProfitConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(EcologyCollectionShareProfitConf::getConfId, confId);
        return count(wrapper) > 0;
    }
}
